package com.wyl.wyl.testapplication.utils;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;


import com.wyl.wyl.testapplication.R;
import com.wyl.wyl.testapplication.activity.PersonActivity;
import com.wyl.wyl.testapplication.activity.SetActivity;
import com.wyl.wyl.testapplication.activity.WebActivity;
import com.wyl.wyl.testapplication.bean.FunctionItem;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by leij on 2017/6/7.
 */

public class ActivityUtils {

    public static final int REQUEST_CODE_SYSTEM_SETTING = 1001;


    public static List<FunctionItem> getFunctionItemList(Context context , boolean flag) {
        List<FunctionItem> result = new ArrayList<>();

        FunctionItem functionItem;
        functionItem = new FunctionItem();
        functionItem.setPic(R.drawable.pick_up);
        functionItem.setId("20206");
        functionItem.setFunctionName("排队叫号");
        functionItem.setForResult(true);
        functionItem.setClassName(PersonActivity.class);
        result.add(functionItem);

        if (flag){
            functionItem = new FunctionItem();
            functionItem.setPic(R.drawable.chart_two);
            functionItem.setId("20205");
            functionItem.setFunctionName("作业量统计");
            functionItem.setForResult(true);
            functionItem.setClassName(WebActivity.class);
            result.add(functionItem);
        }
        functionItem = new FunctionItem();
        functionItem.setPic(R.drawable.function_logo_system_setting);
        functionItem.setId("20208");
        functionItem.setFunctionName("设置");
//        functionItem.setForResult(true);
        functionItem.setClassName(SetActivity.class);
        result.add(functionItem);

        return result;
    }


    public static RelativeLayout initBackAndFunction(Activity activity, int resourceId, View.OnClickListener onclickListener) {
        return initBackAndFunction(activity, activity.getResources().getString(resourceId), onclickListener);
    }

    public static RelativeLayout initBackAndFunction(Activity activity, String text, View.OnClickListener onclickListener) {
        RelativeLayout leftTitleLayout = (RelativeLayout) activity.findViewById(R.id.leftTitleLayout);
        View backAndNameView = LayoutInflater.from(activity).inflate(R.layout.include_back_and_name, null);
        TextView functionName = (TextView) backAndNameView.findViewById(R.id.functionName);
        leftTitleLayout.addView(backAndNameView);
        functionName.setText("返回");
        leftTitleLayout.setOnClickListener(onclickListener);
        return leftTitleLayout;
    }

    public static RelativeLayout  initRightFunction(Activity activity, View view, View.OnClickListener onclickListener) {
        RelativeLayout rightTitleLayout = (RelativeLayout) activity.findViewById(R.id.rightTitleLayout);
        rightTitleLayout.addView(view);
        rightTitleLayout.setOnClickListener(onclickListener);
        return rightTitleLayout;
    }

    public static View getRightViewWithName(Context context, String name) {
        View rightFunctionView = LayoutInflater.from(context).inflate(R.layout.include_right_function, null);
        ImageView rightFunction = (ImageView) rightFunctionView.findViewById(R.id.rightFunction);
        rightFunction.setVisibility(View.GONE);
        TextView functionName = (TextView) rightFunctionView.findViewById(R.id.functionName);
        functionName.setText(name);
        return rightFunctionView;
    }

}
